Skip to content

fix(modal): prevent double safe-area in fullscreen modals with ion-content (#31015)#31051

Open
Vitalcheffe wants to merge 2 commits intoionic-team:mainfrom
Vitalcheffe:fix/fullscreen-modal-double-safearea-31015
Open

fix(modal): prevent double safe-area in fullscreen modals with ion-content (#31015)#31051
Vitalcheffe wants to merge 2 commits intoionic-team:mainfrom
Vitalcheffe:fix/fullscreen-modal-double-safearea-31015

Conversation

@Vitalcheffe
Copy link
Copy Markdown

Problem

After upgrading from @ionic/angular 8.7.17 to 8.8.1, fullscreen modals with ion-content but no ion-footer display a white gap at the bottom on iOS devices with a home indicator.

This is a regression from PR #30949, which added applyFullscreenSafeArea(). The function applies wrapper-level padding-bottom for modals with ion-content and no ion-footer. However, ion-content already handles bottom safe-area internally via its scroll container, creating double compensation.

Root cause

The condition "if (!hasContent || hasFooter) return" means padding is applied when hasContent && !hasFooter. But ion-content already manages its own safe-area insets, so the wrapper-level padding creates an extra offset.

Fix

Changed the condition to "if (hasContent || hasFooter) return" — skip wrapper padding when ion-content is present (it handles safe area internally) or when ion-footer is present (it handles its own padding). Only apply wrapper padding for custom modals with raw HTML that lack both.

Impact

  • Fixes the white gap regression for the common pattern: modals with ion-content and no ion-footer
  • Preserves safe-area handling for custom modals without ion-content
  • No breaking changes to existing ion-footer behavior

Fixes #31015

…ntent

applyFullscreenSafeArea() was applying wrapper-level padding-bottom for
modals with ion-content but no ion-footer. Since ion-content already
handles bottom safe-area internally via its scroll container, this
created double compensation — visible as a white gap at the bottom of
fullscreen modals on iOS devices with home indicators.

Fix: skip wrapper padding when ion-content is present, since it already
manages its own safe-area insets. Only apply wrapper padding for custom
modals with raw HTML that lack ion-content.

Fixes ionic-team#31015
@Vitalcheffe Vitalcheffe requested a review from a team as a code owner March 30, 2026 22:44
@Vitalcheffe Vitalcheffe requested a review from gnbm March 30, 2026 22:44
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

@Vitalcheffe is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the package: core @ionic/core package label Mar 30, 2026
@ShaneK
Copy link
Copy Markdown
Member

ShaneK commented Apr 2, 2026

Thanks for the investigation here, the root cause in #31015 is spot on. ion-content handles its own bottom safe-area, so the wrapper padding was doubling it.

There's an e2e test failing in CI from this though. Check shard 11, specifically core/src/components/modal/test/safe-area/modal.e2e.ts:103 ("fullscreen modal without footer should have wrapper padding-bottom"). It was added in #30949 alongside applyFullscreenSafeArea() and expects wrapper padding for exactly this case. That test will need updating to match the new behavior.

In general when changing a condition in a function, it's worth checking if there are tests covering the other branches too, not just the scenario you're fixing. Running npm run test.e2e src/components/modal/test/safe-area from core/ would've caught this locally.

Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! There's a few issues with this, mostly in that it was untested and affects cases other than the intended one.

…ntent

- ion-content handles bottom safe-area internally via its scroll container
- Previously, wrapper padding was applied when hasContent && !hasFooter,
  causing double compensation visible as a white gap on iOS
- Now skips wrapper padding whenever ion-content is present
- Raw HTML modals (no content, no footer) remain untouched as before
- Fixes ionic-team#31015
@Vitalcheffe
Copy link
Copy Markdown
Author

Good catch — the original flip was too aggressive. Updated the logic to be explicit:

  1. If ion-content is present → skip wrapper padding entirely (content handles safe-area)
  2. If no content AND has footer → apply wrapper padding (standard Ionic layout)
  3. If no content AND no footer → skip (raw HTML, developer-controlled)

This correctly fixes the double compensation for ion-content modals (#31015) while preserving the original behavior for all other cases.

@ShaneK
Copy link
Copy Markdown
Member

ShaneK commented Apr 2, 2026

The existing e2e test still isn't updated and will fail in CI again once the full suite runs on this commit, same as last time. Your if (hasContent) return; correctly skips wrapper padding now, but the test still asserts it's set.

If you're able to run the tests locally (npm run test.e2e src/components/modal/test/safe-area from core/), that would help catch these before pushing. If setting up the test environment is a blocker, let us know and we can help. We will need to close this if we can't get the tests passing though, so just flag it and we'll figure something out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: applyFullscreenSafeArea() shrinks fullscreen modal wrapper when ion-content exists without ion-footer (8.8.1 regression)

2 participants